package org.jason.user.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaIgnore;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jason.common.satoken.annotation.SaInterior;
import org.jason.model.common.dtos.ResponseResult;
import org.jason.model.user.dtos.LoginDto;
import org.jason.model.user.pojos.CuUserRole;
import org.jason.model.user.pojos.UserRolePermission;
import org.jason.user.service.ICuUserService;
import org.jason.user.service.IUserRolePermService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户权限接口
 */
@Api("用户权限接口")
@RestController
@RequestMapping("/auth")
public class UserAuthController {

    @Autowired
    private IUserRolePermService userRolePermService;

    @Autowired
    private ICuUserService userService;

    @ApiOperation("获取用户权限表")
    @SaInterior
    @GetMapping("/{userId}")
    public ResponseResult<UserRolePermission> getUserRolePermission(@PathVariable Integer userId){
        return userRolePermService.getUserRolePermission(userId);
    }

    //后台登录
    @ApiOperation("后台登录")
    @SaIgnore
    @PostMapping("/login")
    public ResponseResult backstageLogin(@RequestBody @Validated LoginDto dto){
        return userService.backstageLogin(dto);
    }
}
